package com.example.easybuy;

import com.example.easybuy.service.DataSyncService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;

@SpringBootApplication
@MapperScan("com.example.easybuy.mapper")
public class EasybuyApplication {
    
    @Autowired
    private DataSyncService dataSyncService;
    
    public static void main(String[] args) {
        SpringApplication.run(EasybuyApplication.class, args);
    }
    
    @EventListener(ApplicationReadyEvent.class)
    public void syncDataOnStartup() {
        dataSyncService.syncData();
    }
}